package com.hjy.hjyojbackendquestionservice.rabbitMq;

import com.hjy.hjyojbackendcommon.constant.OjMqConstant;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @version 1.0
 * @Author HJY_Maker
 * @Date 2024/7/8 星期一 21:51
 */
@Component
public class MqMessageProducer {
    //此注入的类似于注入mybatis-plus的mapper
    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送消息
     *
     * @param message
     */
    public void sendMessage(String exchange, String routingKey, String message) {
        rabbitTemplate.convertAndSend(OjMqConstant.OJ_EXCHANGE_NAME, OjMqConstant.OJ_ROUTING_KEY, message);
    }
}
